<%--
  Created by IntelliJ IDEA.
  User: JD
  Date: 2023/9/20
  Time: 15:12
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="<%=basePath%>static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="<%=basePath%>static/css/font.css">
    <link rel="stylesheet" href="<%=basePath%>static/css/xadmin.css">
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="ticketid" class="layui-form-label">
                门票编号
            </label>
            <div class="layui-input-inline">
                <input type="ticketid" readonly id="ticketid" name="ticketid"
                       autocomplete="off" class="layui-input" value="${ticket.ticketid}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ticketname" class="layui-form-label">
                票名
            </label>
            <div class="layui-input-inline">
                <input type="ticketname" id="ticketname" name="ticketname"
                       autocomplete="off" class="layui-input" value="${ticket.ticketname}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="price" class="layui-form-label">
                价格
            </label>
            <div class="layui-input-inline">
                <input type="price" id="price" name="price"
                       autocomplete="off" class="layui-input" value="${ticket.price}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ticketsum" class="layui-form-label">
                票总量
            </label>
            <div class="layui-input-inline">
                <input type="ticketsum" id="ticketsum" name="ticketsum"
                       autocomplete="off" class="layui-input" value="${ticket.ticketsum}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ticketsum" class="layui-form-label">
                票余量
            </label>
            <div class="layui-input-inline">
                <input type="ticketnum" id="ticketnum" name="ticketnum"
                       autocomplete="off" class="layui-input" value="${ticket.ticketnum}">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" id="L_repass" type="button">
                修改
            </button>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
    $(document).on('click', '#L_repass', function() {
        submit();
    });
    function submit(){

        let ticket = {
            ticketid:$("#ticketid").val(),
            ticketname: $("#ticketname").val(),
            price: $("#price").val(),
            ticketsum: $("#ticketsum").val(),
            ticketnum: $("#ticketnum").val(),
        }
        console.log(JSON.stringify(ticket));

        $.ajax({
            url: "/ticket/updateTicket",
            type: "post",
            datatype: "json",
            contentType: "application/json",
            data: JSON.stringify(ticket),
            success: function (data){
                alert("修改成功！");
                window.parent.location.reload();//刷新父页面
                parent.layer.close(layer.index);//关闭弹出层
            },
            error: function (data){
                alert("修改失败！");
            }
        })
    }
</script>
</html>
